package com.bjfu.demo.dao;

import com.bjfu.demo.dto.StatisticRawResult;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.Date;
import java.util.List;

/**
 *     private String siteCode;
 *     private String airLevelCode;
 *     private Date lastUpdateTime;
 *     private String district;
 *     private Integer totalNum;
 *     private Integer effectingNum;
 *     private String siteName;
 *     private Integer effectingRation;
 */
@Mapper
public interface NewStatisticMapper {
    @Select("SELECT\n" +
            "\tSITECODE siteCode,\n" +
            "\tCOUNT(*) totalNum,\n" +
            "\tCOUNT(\n" +
            "\tIF\n" +
            "\t( AIRLEVELCODE = '--', NULL, AIRLEVELCODE )) effectingNum \n" +
            "FROM\n" +
            "\trp_data \n" +
            "WHERE\n" +
            "\tLASTUPDATETIME > #{lastYearBeginDate} \n" +
            "\tAND LASTUPDATETIME < #{lastYearEndDate} \n" +
            "GROUP BY\n" +
            "\tSITECODE")
    List<StatisticRawResult> getResultByPeriod(@Param("lastYearBeginDate") Date lastYearBeginDate,@Param("lastYearEndDate") Date lastYearEndDate);
}
